<template>
    <div>
        <mHeader></mHeader>
        <div class="main-con">
            <div class="left_main">
                <leftMenu />
            </div>
            <div class="rightMain">
                <!-- 人物 -->
                <div class="top">
                    <span> {{ title }}</span>
                    <!-- <span>作者 / {{ author }}</span> -->
                    <!-- <strong> 红楼梦/石头记</strong>
                    <span>作者 / 张三，李四</span> -->
                </div>
                <div class="r_main">
                    <div class="left-menu">
                        <div @click="goPage('/column/basic', id)" :class="{ active: path == '/column/basic' }">
                            <span>基本信息</span>
                        </div>
                        <div @click="goPage('/column/list', id)" :class="{ active: path == '/column/list' }">
                            <span>专栏目录</span>
                        </div>
                        <div @click="goPage('/column/setUp', id)" :class="{ active: path == '/column/setUp' }">
                            <span>专栏运营</span>
                        </div>
                        <!-- <div @click="goPage('/column/user', id)" :class="{ active: path == '/column/user' }"
                            v-if="type == 3">
                            <span>用户列表</span>
                        </div> -->
                    </div>
                    <div class="form_con">
                        <router-view @ids="ids"></router-view>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import leftMenu from '@/components/leftMenu.vue';
export default {
    components: {
        leftMenu
    },
    data() {
        return {
            title: '基本信息',
            author: '',
            userInfo: {},
            id: '',
            info: {},
            type: 1
        };
    },
    computed: {
        path() {
            return this.$route.path
        }
    },
    mounted() {
        this.id = this.$route.query.id
        this.userInfo = JSON.parse(localStorage.getItem('userInfo'))
        console.log('获取到的id', this.id)
        if (this.id) {
            this.getInfo()
        } else {
            this.title = '基本信息'
            this.author = this.userInfo.user_nickname
        }
    },
    methods: {
        // 获取专栏详情
        getInfo() {
            let params = {
                id: this.id
            }
            this.$api.colInfo(params).then(res => {
                console.log(res)
                if (res.data.code == 1) {
                    this.info = res.data.data
                    this.title = res.data.data.title
                    this.type = res.data.data.type
                    this.author = res.data.data.author
                }
            })
        },
        ids(id) {
            console.log("id", id);
            this.id = id
            this.getInfo()
        },
        onSubmit() {
            console.log('submit!', this.form);
        },
        goPage(url, id) {

            let cid = this.$route.query.id
            if (this.path != url && cid) {
                this.$router.push({
                    path: url,
                    query: {
                        id: this.id
                    }
                })
            }

            if (this.path != url && !cid) {
                this.$message.closeAll()
                this.$message.error('请先创建专栏');
            }
            // if (id && cid != id) {
            //     this.$router.push({
            //         path: url,
            //         query: {
            //             id
            //         }
            //     })
            // }
        }
    },
}
</script>
<style lang="scss" scoped>
.main-con {
    display: flex;

    .left_main {
        margin-right: 1.04rem;
    }
}

.rightMain {
    flex: 1;

    .top {
        padding: 1.1rem 1.04rem;
        // height: 4.17rem;
        display: flex;
        align-items: center;
        background-color: #E5E5E5;
        width: 100%;
        height: 60px;
        strong {
            font-weight: bold;
            font-size: 1.50rem;
            color: #1068E7;
            line-height: 1.97rem;
            font-family: Microsoft YaHei;
        }

        span {
            font-weight: bold;
            font-size: 24px;
            color: #1068E7;
        }
    }

    .r_main {
        display: flex;

        .left-menu {
            padding: 0 0.85rem;
            border-right: 0.01rem solid #E8E8E8;

            >div {
                width: 6.25rem;
                height: 98px;
                display: flex;
                align-items: center;
                justify-content: center;
                border-bottom: 0.01rem solid #E8E8E8;
                cursor: pointer;

                &:last-child {
                    border: none;
                }

                span {
                    font-weight: 400;
                    font-size: 1.04rem;
                    color: #000000;
                    font-weight: 400;
                }
            }

            .active {
                span {
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    width: 6.25rem;
                    height: 2.5rem;
                    background: #4ABAFF;
                    border-radius: 0.31rem;
                    color: #FFFFFF;
                }
            }
        }

        .form_con {


            flex: 1;
            // overflow-y: auto;
        }
    }
}
</style>